﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace LogExport.UI.Tools
{
    public class TxtReader : IDataReader
    {

        IDataReader reader;
        public TxtReader(IDataReader reader)
        {
            this.reader = reader;
        }

        #region IDataReader 成员

        public void Close()
        {
            this.reader.Close();
        }

        public int Depth
        {
            get { return this.reader.Depth; }
        }

        public DataTable GetSchemaTable()
        {
            return this.reader.GetSchemaTable();
        }

        public bool IsClosed
        {
            get { return this.reader.IsClosed; }
        }

        public bool NextResult()
        {
            return this.reader.NextResult();
        }

        public bool Read()
        {
            bool isok =  this.reader.Read();
            while (isok && (this.reader.IsDBNull(0) ||                 
                this.reader.GetValue(0).ToString().StartsWith("#")))
            {
                //this.reader.GetBytes(0, 0, buffer, 0, 0);
                //if()
                //{
                    //#Fields:
                //}
                isok = this.reader.Read();
            }
            return isok;
        }

        public int RecordsAffected
        {
            get { return this.reader.RecordsAffected; }
        }

        #endregion

        #region IDisposable 成员

        public void Dispose()
        {
            this.reader.Dispose();
        }

        #endregion

        #region IDataRecord 成员

        public int FieldCount
        {
            get { return this.reader.FieldCount; }
        }

        public bool GetBoolean(int i)
        {
            return this.reader.GetBoolean(i);
        }

        public byte GetByte(int i)
        {
            return this.reader.GetByte(i);
        }

        public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
        {
            return this.reader.GetBytes(i, fieldOffset, buffer, bufferoffset, length);
        }

        public char GetChar(int i)
        {
            return this.reader.GetChar(i);
        }

        public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
        {
            return this.reader.GetChars(i, fieldoffset, buffer, bufferoffset, length);
        }

        public IDataReader GetData(int i)
        {
            return this.reader.GetData(i);
        }

        public string GetDataTypeName(int i)
        {
            return this.reader.GetDataTypeName(i);
        }

        public DateTime GetDateTime(int i)
        {
            return this.reader.GetDateTime(i);
        }

        public decimal GetDecimal(int i)
        {
            return this.reader.GetDecimal(i);
        }

        public double GetDouble(int i)
        {
            return this.reader.GetDouble(i);
        }

        public Type GetFieldType(int i)
        {
            return this.reader.GetFieldType(i);
        }

        public float GetFloat(int i)
        {
            return this.reader.GetFloat(i);
        }

        public Guid GetGuid(int i)
        {
            return this.reader.GetGuid(i);
        }

        public short GetInt16(int i)
        {
            return this.reader.GetInt16(i);
        }

        public int GetInt32(int i)
        {
            return this.reader.GetInt32(i);
        }

        public long GetInt64(int i)
        {
            return this.reader.GetInt64(i);
        }

        public string GetName(int i)
        {
            return this.reader.GetName(i);
        }

        public int GetOrdinal(string name)
        {
            return this.reader.GetOrdinal(name);
        }

        public string GetString(int i)
        {
            return this.reader.GetString(i);
        }

        public object GetValue(int i)
        {
            return this.reader.GetValue(i);
        }

        public int GetValues(object[] values)
        {
            return this.reader.GetValues(values);
        }

        public bool IsDBNull(int i)
        {
            return this.reader.IsDBNull(i);
        }

        public object this[string name]
        {
            get { return this.reader[name]; }
        }

        public object this[int i]
        {
            get { return this.reader[i]; }
        }

        #endregion
    }
}